1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module glib.BookmarkFile; 26 27 private import glib.ConstructionException; 28 private import glib.DateTime; 29 private import glib.ErrorG; 30 private import glib.GException; 31 private import glib.Str; 32 private import glib.c.functions; 33 public import glib.c.types; 34 private import linker.Loader; 35 36 37 /** 38 * An opaque data structure representing a set of bookmarks. 39 */ 40 public class BookmarkFile 41 { 42 /** the main Gtk struct */ 43 protected GBookmarkFile* gBookmarkFile; 44 protected bool ownedRef; 45 46 /** Get the main Gtk struct */ 47 public GBookmarkFile* getBookmarkFileStruct(bool transferOwnership = false) 48 { 49 if (transferOwnership) 50 ownedRef = false; 51 return gBookmarkFile; 52 } 53 54 /** the main Gtk struct as a void* */ 55 protected void* getStruct() 56 { 57 return cast(void*)gBookmarkFile; 58 } 59 60 /** 61 * Sets our main struct and passes it to the parent class. 62 */ 63 public this (GBookmarkFile* gBookmarkFile, bool ownedRef = false) 64 { 65 this.gBookmarkFile = gBookmarkFile; 66 this.ownedRef = ownedRef; 67 } 68 69 ~this () 70 { 71 if ( Linker.isLoaded(LIBRARY_GLIB[0]) && ownedRef ) 72 g_bookmark_file_free(gBookmarkFile); 73 } 74 75 76 /** 77 * Adds the application with @name and @exec to the list of 78 * applications that have registered a bookmark for @uri into 79 * @bookmark. 80 * 81 * Every bookmark inside a #GBookmarkFile must have at least an 82 * application registered. Each application must provide a name, a 83 * command line useful for launching the bookmark, the number of times 84 * the bookmark has been registered by the application and the last 85 * time the application registered this bookmark. 86 * 87 * If @name is %NULL, the name of the application will be the 88 * same returned by g_get_application_name(); if @exec is %NULL, the 89 * command line will be a composition of the program name as 90 * returned by g_get_prgname() and the "\%u" modifier, which will be 91 * expanded to the bookmark's URI. 92 * 93 * This function will automatically take care of updating the 94 * registrations count and timestamping in case an application 95 * with the same @name had already registered a bookmark for 96 * @uri inside @bookmark. 97 * 98 * If no bookmark for @uri is found, one is created. 99 * 100 * Params: 101 * uri = a valid URI 102 * name = the name of the application registering the bookmark 103 * or %NULL 104 * exec = command line to be used to launch the bookmark or %NULL 105 * 106 * Since: 2.12 107 */ 108 public void addApplication(string uri, string name, string exec) 109 { 110 g_bookmark_file_add_application(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), Str.toStringz(exec)); 111 } 112 113 /** 114 * Adds @group to the list of groups to which the bookmark for @uri 115 * belongs to. 116 * 117 * If no bookmark for @uri is found then it is created. 118 * 119 * Params: 120 * uri = a valid URI 121 * group = the group name to be added 122 * 123 * Since: 2.12 124 */ 125 public void addGroup(string uri, string group) 126 { 127 g_bookmark_file_add_group(gBookmarkFile, Str.toStringz(uri), Str.toStringz(group)); 128 } 129 130 /** 131 * Frees a #GBookmarkFile. 132 * 133 * Since: 2.12 134 */ 135 public void free() 136 { 137 g_bookmark_file_free(gBookmarkFile); 138 ownedRef = false; 139 } 140 141 /** 142 * Gets the time the bookmark for @uri was added to @bookmark 143 * 144 * In the event the URI cannot be found, -1 is returned and 145 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 146 * 147 * Deprecated: Use g_bookmark_file_get_added_date_time() instead, as 148 * `time_t` is deprecated due to the year 2038 problem. 149 * 150 * Params: 151 * uri = a valid URI 152 * 153 * Returns: a timestamp 154 * 155 * Since: 2.12 156 * 157 * Throws: GException on failure. 158 */ 159 public uint getAdded(string uri) 160 { 161 GError* err = null; 162 163 auto __p = g_bookmark_file_get_added(gBookmarkFile, Str.toStringz(uri), &err); 164 165 if (err !is null) 166 { 167 throw new GException( new ErrorG(err) ); 168 } 169 170 return __p; 171 } 172 173 /** 174 * Gets the time the bookmark for @uri was added to @bookmark 175 * 176 * In the event the URI cannot be found, %NULL is returned and 177 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 178 * 179 * Params: 180 * uri = a valid URI 181 * 182 * Returns: a #GDateTime 183 * 184 * Since: 2.66 185 * 186 * Throws: GException on failure. 187 */ 188 public DateTime getAddedDateTime(string uri) 189 { 190 GError* err = null; 191 192 auto __p = g_bookmark_file_get_added_date_time(gBookmarkFile, Str.toStringz(uri), &err); 193 194 if (err !is null) 195 { 196 throw new GException( new ErrorG(err) ); 197 } 198 199 if(__p is null) 200 { 201 return null; 202 } 203 204 return new DateTime(cast(GDateTime*) __p); 205 } 206 207 /** 208 * Gets the registration information of @app_name for the bookmark for 209 * @uri. See g_bookmark_file_set_application_info() for more information about 210 * the returned data. 211 * 212 * The string returned in @app_exec must be freed. 213 * 214 * In the event the URI cannot be found, %FALSE is returned and 215 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the 216 * event that no application with name @app_name has registered a bookmark 217 * for @uri, %FALSE is returned and error is set to 218 * %G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting 219 * the command line fails, an error of the %G_SHELL_ERROR domain is 220 * set and %FALSE is returned. 221 * 222 * Deprecated: Use g_bookmark_file_get_application_info() instead, as 223 * `time_t` is deprecated due to the year 2038 problem. 224 * 225 * Params: 226 * uri = a valid URI 227 * name = an application's name 228 * exec = return location for the command line of the application, or %NULL 229 * count = return location for the registration count, or %NULL 230 * stamp = return location for the last registration time, or %NULL 231 * 232 * Returns: %TRUE on success. 233 * 234 * Since: 2.12 235 * 236 * Throws: GException on failure. 237 */ 238 public bool getAppInfo(string uri, string name, out string exec, out uint count, out uint stamp) 239 { 240 char* outexec = null; 241 GError* err = null; 242 243 auto __p = g_bookmark_file_get_app_info(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), &outexec, &count, &stamp, &err) != 0; 244 245 if (err !is null) 246 { 247 throw new GException( new ErrorG(err) ); 248 } 249 250 exec = Str.toString(outexec); 251 252 return __p; 253 } 254 255 /** 256 * Gets the registration information of @app_name for the bookmark for 257 * @uri. See g_bookmark_file_set_application_info() for more information about 258 * the returned data. 259 * 260 * The string returned in @app_exec must be freed. 261 * 262 * In the event the URI cannot be found, %FALSE is returned and 263 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the 264 * event that no application with name @app_name has registered a bookmark 265 * for @uri, %FALSE is returned and error is set to 266 * %G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting 267 * the command line fails, an error of the %G_SHELL_ERROR domain is 268 * set and %FALSE is returned. 269 * 270 * Params: 271 * uri = a valid URI 272 * name = an application's name 273 * exec = return location for the command line of the application, or %NULL 274 * count = return location for the registration count, or %NULL 275 * stamp = return location for the last registration time, or %NULL 276 * 277 * Returns: %TRUE on success. 278 * 279 * Since: 2.66 280 * 281 * Throws: GException on failure. 282 */ 283 public bool getApplicationInfo(string uri, string name, out string exec, out uint count, out DateTime stamp) 284 { 285 char* outexec = null; 286 GDateTime* outstamp = null; 287 GError* err = null; 288 289 auto __p = g_bookmark_file_get_application_info(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), &outexec, &count, &outstamp, &err) != 0; 290 291 if (err !is null) 292 { 293 throw new GException( new ErrorG(err) ); 294 } 295 296 exec = Str.toString(outexec); 297 stamp = new DateTime(outstamp); 298 299 return __p; 300 } 301 302 /** 303 * Retrieves the names of the applications that have registered the 304 * bookmark for @uri. 305 * 306 * In the event the URI cannot be found, %NULL is returned and 307 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 308 * 309 * Params: 310 * uri = a valid URI 311 * 312 * Returns: a newly allocated %NULL-terminated array of strings. 313 * Use g_strfreev() to free it. 314 * 315 * Since: 2.12 316 * 317 * Throws: GException on failure. 318 */ 319 public string[] getApplications(string uri) 320 { 321 size_t length; 322 GError* err = null; 323 324 auto retStr = g_bookmark_file_get_applications(gBookmarkFile, Str.toStringz(uri), &length, &err); 325 326 if (err !is null) 327 { 328 throw new GException( new ErrorG(err) ); 329 } 330 331 scope(exit) Str.freeStringArray(retStr); 332 return Str.toStringArray(retStr, length); 333 } 334 335 /** 336 * Retrieves the description of the bookmark for @uri. 337 * 338 * In the event the URI cannot be found, %NULL is returned and 339 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 340 * 341 * Params: 342 * uri = a valid URI 343 * 344 * Returns: a newly allocated string or %NULL if the specified 345 * URI cannot be found. 346 * 347 * Since: 2.12 348 * 349 * Throws: GException on failure. 350 */ 351 public string getDescription(string uri) 352 { 353 GError* err = null; 354 355 auto retStr = g_bookmark_file_get_description(gBookmarkFile, Str.toStringz(uri), &err); 356 357 if (err !is null) 358 { 359 throw new GException( new ErrorG(err) ); 360 } 361 362 scope(exit) Str.freeString(retStr); 363 return Str.toString(retStr); 364 } 365 366 /** 367 * Retrieves the list of group names of the bookmark for @uri. 368 * 369 * In the event the URI cannot be found, %NULL is returned and 370 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 371 * 372 * The returned array is %NULL terminated, so @length may optionally 373 * be %NULL. 374 * 375 * Params: 376 * uri = a valid URI 377 * 378 * Returns: a newly allocated %NULL-terminated array of group names. 379 * Use g_strfreev() to free it. 380 * 381 * Since: 2.12 382 * 383 * Throws: GException on failure. 384 */ 385 public string[] getGroups(string uri) 386 { 387 size_t length; 388 GError* err = null; 389 390 auto retStr = g_bookmark_file_get_groups(gBookmarkFile, Str.toStringz(uri), &length, &err); 391 392 if (err !is null) 393 { 394 throw new GException( new ErrorG(err) ); 395 } 396 397 scope(exit) Str.freeStringArray(retStr); 398 return Str.toStringArray(retStr, length); 399 } 400 401 /** 402 * Gets the icon of the bookmark for @uri. 403 * 404 * In the event the URI cannot be found, %FALSE is returned and 405 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 406 * 407 * Params: 408 * uri = a valid URI 409 * href = return location for the icon's location or %NULL 410 * mimeType = return location for the icon's MIME type or %NULL 411 * 412 * Returns: %TRUE if the icon for the bookmark for the URI was found. 413 * You should free the returned strings. 414 * 415 * Since: 2.12 416 * 417 * Throws: GException on failure. 418 */ 419 public bool getIcon(string uri, out string href, out string mimeType) 420 { 421 char* outhref = null; 422 char* outmimeType = null; 423 GError* err = null; 424 425 auto __p = g_bookmark_file_get_icon(gBookmarkFile, Str.toStringz(uri), &outhref, &outmimeType, &err) != 0; 426 427 if (err !is null) 428 { 429 throw new GException( new ErrorG(err) ); 430 } 431 432 href = Str.toString(outhref); 433 mimeType = Str.toString(outmimeType); 434 435 return __p; 436 } 437 438 /** 439 * Gets whether the private flag of the bookmark for @uri is set. 440 * 441 * In the event the URI cannot be found, %FALSE is returned and 442 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the 443 * event that the private flag cannot be found, %FALSE is returned and 444 * @error is set to %G_BOOKMARK_FILE_ERROR_INVALID_VALUE. 445 * 446 * Params: 447 * uri = a valid URI 448 * 449 * Returns: %TRUE if the private flag is set, %FALSE otherwise. 450 * 451 * Since: 2.12 452 * 453 * Throws: GException on failure. 454 */ 455 public bool getIsPrivate(string uri) 456 { 457 GError* err = null; 458 459 auto __p = g_bookmark_file_get_is_private(gBookmarkFile, Str.toStringz(uri), &err) != 0; 460 461 if (err !is null) 462 { 463 throw new GException( new ErrorG(err) ); 464 } 465 466 return __p; 467 } 468 469 /** 470 * Retrieves the MIME type of the resource pointed by @uri. 471 * 472 * In the event the URI cannot be found, %NULL is returned and 473 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the 474 * event that the MIME type cannot be found, %NULL is returned and 475 * @error is set to %G_BOOKMARK_FILE_ERROR_INVALID_VALUE. 476 * 477 * Params: 478 * uri = a valid URI 479 * 480 * Returns: a newly allocated string or %NULL if the specified 481 * URI cannot be found. 482 * 483 * Since: 2.12 484 * 485 * Throws: GException on failure. 486 */ 487 public string getMimeType(string uri) 488 { 489 GError* err = null; 490 491 auto retStr = g_bookmark_file_get_mime_type(gBookmarkFile, Str.toStringz(uri), &err); 492 493 if (err !is null) 494 { 495 throw new GException( new ErrorG(err) ); 496 } 497 498 scope(exit) Str.freeString(retStr); 499 return Str.toString(retStr); 500 } 501 502 /** 503 * Gets the time when the bookmark for @uri was last modified. 504 * 505 * In the event the URI cannot be found, -1 is returned and 506 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 507 * 508 * Deprecated: Use g_bookmark_file_get_modified_date_time() instead, as 509 * `time_t` is deprecated due to the year 2038 problem. 510 * 511 * Params: 512 * uri = a valid URI 513 * 514 * Returns: a timestamp 515 * 516 * Since: 2.12 517 * 518 * Throws: GException on failure. 519 */ 520 public uint getModified(string uri) 521 { 522 GError* err = null; 523 524 auto __p = g_bookmark_file_get_modified(gBookmarkFile, Str.toStringz(uri), &err); 525 526 if (err !is null) 527 { 528 throw new GException( new ErrorG(err) ); 529 } 530 531 return __p; 532 } 533 534 /** 535 * Gets the time when the bookmark for @uri was last modified. 536 * 537 * In the event the URI cannot be found, %NULL is returned and 538 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 539 * 540 * Params: 541 * uri = a valid URI 542 * 543 * Returns: a #GDateTime 544 * 545 * Since: 2.66 546 * 547 * Throws: GException on failure. 548 */ 549 public DateTime getModifiedDateTime(string uri) 550 { 551 GError* err = null; 552 553 auto __p = g_bookmark_file_get_modified_date_time(gBookmarkFile, Str.toStringz(uri), &err); 554 555 if (err !is null) 556 { 557 throw new GException( new ErrorG(err) ); 558 } 559 560 if(__p is null) 561 { 562 return null; 563 } 564 565 return new DateTime(cast(GDateTime*) __p); 566 } 567 568 /** 569 * Gets the number of bookmarks inside @bookmark. 570 * 571 * Returns: the number of bookmarks 572 * 573 * Since: 2.12 574 */ 575 public int getSize() 576 { 577 return g_bookmark_file_get_size(gBookmarkFile); 578 } 579 580 /** 581 * Returns the title of the bookmark for @uri. 582 * 583 * If @uri is %NULL, the title of @bookmark is returned. 584 * 585 * In the event the URI cannot be found, %NULL is returned and 586 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 587 * 588 * Params: 589 * uri = a valid URI or %NULL 590 * 591 * Returns: a newly allocated string or %NULL if the specified 592 * URI cannot be found. 593 * 594 * Since: 2.12 595 * 596 * Throws: GException on failure. 597 */ 598 public string getTitle(string uri) 599 { 600 GError* err = null; 601 602 auto retStr = g_bookmark_file_get_title(gBookmarkFile, Str.toStringz(uri), &err); 603 604 if (err !is null) 605 { 606 throw new GException( new ErrorG(err) ); 607 } 608 609 scope(exit) Str.freeString(retStr); 610 return Str.toString(retStr); 611 } 612 613 /** 614 * Returns all URIs of the bookmarks in the bookmark file @bookmark. 615 * The array of returned URIs will be %NULL-terminated, so @length may 616 * optionally be %NULL. 617 * 618 * Returns: a newly allocated %NULL-terminated array of strings. 619 * Use g_strfreev() to free it. 620 * 621 * Since: 2.12 622 */ 623 public string[] getUris() 624 { 625 size_t length; 626 627 auto retStr = g_bookmark_file_get_uris(gBookmarkFile, &length); 628 629 scope(exit) Str.freeStringArray(retStr); 630 return Str.toStringArray(retStr, length); 631 } 632 633 /** 634 * Gets the time the bookmark for @uri was last visited. 635 * 636 * In the event the URI cannot be found, -1 is returned and 637 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 638 * 639 * Deprecated: Use g_bookmark_file_get_visited_date_time() instead, as 640 * `time_t` is deprecated due to the year 2038 problem. 641 * 642 * Params: 643 * uri = a valid URI 644 * 645 * Returns: a timestamp. 646 * 647 * Since: 2.12 648 * 649 * Throws: GException on failure. 650 */ 651 public uint getVisited(string uri) 652 { 653 GError* err = null; 654 655 auto __p = g_bookmark_file_get_visited(gBookmarkFile, Str.toStringz(uri), &err); 656 657 if (err !is null) 658 { 659 throw new GException( new ErrorG(err) ); 660 } 661 662 return __p; 663 } 664 665 /** 666 * Gets the time the bookmark for @uri was last visited. 667 * 668 * In the event the URI cannot be found, %NULL is returned and 669 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 670 * 671 * Params: 672 * uri = a valid URI 673 * 674 * Returns: a #GDateTime 675 * 676 * Since: 2.66 677 * 678 * Throws: GException on failure. 679 */ 680 public DateTime getVisitedDateTime(string uri) 681 { 682 GError* err = null; 683 684 auto __p = g_bookmark_file_get_visited_date_time(gBookmarkFile, Str.toStringz(uri), &err); 685 686 if (err !is null) 687 { 688 throw new GException( new ErrorG(err) ); 689 } 690 691 if(__p is null) 692 { 693 return null; 694 } 695 696 return new DateTime(cast(GDateTime*) __p); 697 } 698 699 /** 700 * Checks whether the bookmark for @uri inside @bookmark has been 701 * registered by application @name. 702 * 703 * In the event the URI cannot be found, %FALSE is returned and 704 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 705 * 706 * Params: 707 * uri = a valid URI 708 * name = the name of the application 709 * 710 * Returns: %TRUE if the application @name was found 711 * 712 * Since: 2.12 713 * 714 * Throws: GException on failure. 715 */ 716 public bool hasApplication(string uri, string name) 717 { 718 GError* err = null; 719 720 auto __p = g_bookmark_file_has_application(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), &err) != 0; 721 722 if (err !is null) 723 { 724 throw new GException( new ErrorG(err) ); 725 } 726 727 return __p; 728 } 729 730 /** 731 * Checks whether @group appears in the list of groups to which 732 * the bookmark for @uri belongs to. 733 * 734 * In the event the URI cannot be found, %FALSE is returned and 735 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 736 * 737 * Params: 738 * uri = a valid URI 739 * group = the group name to be searched 740 * 741 * Returns: %TRUE if @group was found. 742 * 743 * Since: 2.12 744 * 745 * Throws: GException on failure. 746 */ 747 public bool hasGroup(string uri, string group) 748 { 749 GError* err = null; 750 751 auto __p = g_bookmark_file_has_group(gBookmarkFile, Str.toStringz(uri), Str.toStringz(group), &err) != 0; 752 753 if (err !is null) 754 { 755 throw new GException( new ErrorG(err) ); 756 } 757 758 return __p; 759 } 760 761 /** 762 * Looks whether the desktop bookmark has an item with its URI set to @uri. 763 * 764 * Params: 765 * uri = a valid URI 766 * 767 * Returns: %TRUE if @uri is inside @bookmark, %FALSE otherwise 768 * 769 * Since: 2.12 770 */ 771 public bool hasItem(string uri) 772 { 773 return g_bookmark_file_has_item(gBookmarkFile, Str.toStringz(uri)) != 0; 774 } 775 776 /** 777 * Loads a bookmark file from memory into an empty #GBookmarkFile 778 * structure. If the object cannot be created then @error is set to a 779 * #GBookmarkFileError. 780 * 781 * Params: 782 * data = desktop bookmarks 783 * loaded in memory 784 * 785 * Returns: %TRUE if a desktop bookmark could be loaded. 786 * 787 * Since: 2.12 788 * 789 * Throws: GException on failure. 790 */ 791 public bool loadFromData(string data) 792 { 793 GError* err = null; 794 795 auto __p = g_bookmark_file_load_from_data(gBookmarkFile, Str.toStringz(data), cast(size_t)data.length, &err) != 0; 796 797 if (err !is null) 798 { 799 throw new GException( new ErrorG(err) ); 800 } 801 802 return __p; 803 } 804 805 /** 806 * This function looks for a desktop bookmark file named @file in the 807 * paths returned from g_get_user_data_dir() and g_get_system_data_dirs(), 808 * loads the file into @bookmark and returns the file's full path in 809 * @full_path. If the file could not be loaded then @error is 810 * set to either a #GFileError or #GBookmarkFileError. 811 * 812 * Params: 813 * file = a relative path to a filename to open and parse 814 * fullPath = return location for a string 815 * containing the full path of the file, or %NULL 816 * 817 * Returns: %TRUE if a key file could be loaded, %FALSE otherwise 818 * 819 * Since: 2.12 820 * 821 * Throws: GException on failure. 822 */ 823 public bool loadFromDataDirs(string file, out string fullPath) 824 { 825 char* outfullPath = null; 826 GError* err = null; 827 828 auto __p = g_bookmark_file_load_from_data_dirs(gBookmarkFile, Str.toStringz(file), &outfullPath, &err) != 0; 829 830 if (err !is null) 831 { 832 throw new GException( new ErrorG(err) ); 833 } 834 835 fullPath = Str.toString(outfullPath); 836 837 return __p; 838 } 839 840 /** 841 * Loads a desktop bookmark file into an empty #GBookmarkFile structure. 842 * If the file could not be loaded then @error is set to either a #GFileError 843 * or #GBookmarkFileError. 844 * 845 * Params: 846 * filename = the path of a filename to load, in the 847 * GLib file name encoding 848 * 849 * Returns: %TRUE if a desktop bookmark file could be loaded 850 * 851 * Since: 2.12 852 * 853 * Throws: GException on failure. 854 */ 855 public bool loadFromFile(string filename) 856 { 857 GError* err = null; 858 859 auto __p = g_bookmark_file_load_from_file(gBookmarkFile, Str.toStringz(filename), &err) != 0; 860 861 if (err !is null) 862 { 863 throw new GException( new ErrorG(err) ); 864 } 865 866 return __p; 867 } 868 869 /** 870 * Changes the URI of a bookmark item from @old_uri to @new_uri. Any 871 * existing bookmark for @new_uri will be overwritten. If @new_uri is 872 * %NULL, then the bookmark is removed. 873 * 874 * In the event the URI cannot be found, %FALSE is returned and 875 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 876 * 877 * Params: 878 * oldUri = a valid URI 879 * newUri = a valid URI, or %NULL 880 * 881 * Returns: %TRUE if the URI was successfully changed 882 * 883 * Since: 2.12 884 * 885 * Throws: GException on failure. 886 */ 887 public bool moveItem(string oldUri, string newUri) 888 { 889 GError* err = null; 890 891 auto __p = g_bookmark_file_move_item(gBookmarkFile, Str.toStringz(oldUri), Str.toStringz(newUri), &err) != 0; 892 893 if (err !is null) 894 { 895 throw new GException( new ErrorG(err) ); 896 } 897 898 return __p; 899 } 900 901 /** 902 * Removes application registered with @name from the list of applications 903 * that have registered a bookmark for @uri inside @bookmark. 904 * 905 * In the event the URI cannot be found, %FALSE is returned and 906 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 907 * In the event that no application with name @app_name has registered 908 * a bookmark for @uri, %FALSE is returned and error is set to 909 * %G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. 910 * 911 * Params: 912 * uri = a valid URI 913 * name = the name of the application 914 * 915 * Returns: %TRUE if the application was successfully removed. 916 * 917 * Since: 2.12 918 * 919 * Throws: GException on failure. 920 */ 921 public bool removeApplication(string uri, string name) 922 { 923 GError* err = null; 924 925 auto __p = g_bookmark_file_remove_application(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), &err) != 0; 926 927 if (err !is null) 928 { 929 throw new GException( new ErrorG(err) ); 930 } 931 932 return __p; 933 } 934 935 /** 936 * Removes @group from the list of groups to which the bookmark 937 * for @uri belongs to. 938 * 939 * In the event the URI cannot be found, %FALSE is returned and 940 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. 941 * In the event no group was defined, %FALSE is returned and 942 * @error is set to %G_BOOKMARK_FILE_ERROR_INVALID_VALUE. 943 * 944 * Params: 945 * uri = a valid URI 946 * group = the group name to be removed 947 * 948 * Returns: %TRUE if @group was successfully removed. 949 * 950 * Since: 2.12 951 * 952 * Throws: GException on failure. 953 */ 954 public bool removeGroup(string uri, string group) 955 { 956 GError* err = null; 957 958 auto __p = g_bookmark_file_remove_group(gBookmarkFile, Str.toStringz(uri), Str.toStringz(group), &err) != 0; 959 960 if (err !is null) 961 { 962 throw new GException( new ErrorG(err) ); 963 } 964 965 return __p; 966 } 967 968 /** 969 * Removes the bookmark for @uri from the bookmark file @bookmark. 970 * 971 * Params: 972 * uri = a valid URI 973 * 974 * Returns: %TRUE if the bookmark was removed successfully. 975 * 976 * Since: 2.12 977 * 978 * Throws: GException on failure. 979 */ 980 public bool removeItem(string uri) 981 { 982 GError* err = null; 983 984 auto __p = g_bookmark_file_remove_item(gBookmarkFile, Str.toStringz(uri), &err) != 0; 985 986 if (err !is null) 987 { 988 throw new GException( new ErrorG(err) ); 989 } 990 991 return __p; 992 } 993 994 /** 995 * Sets the time the bookmark for @uri was added into @bookmark. 996 * 997 * If no bookmark for @uri is found then it is created. 998 * 999 * Deprecated: Use g_bookmark_file_set_added_date_time() instead, as 1000 * `time_t` is deprecated due to the year 2038 problem. 1001 * 1002 * Params: 1003 * uri = a valid URI 1004 * added = a timestamp or -1 to use the current time 1005 * 1006 * Since: 2.12 1007 */ 1008 public void setAdded(string uri, uint added) 1009 { 1010 g_bookmark_file_set_added(gBookmarkFile, Str.toStringz(uri), added); 1011 } 1012 1013 /** 1014 * Sets the time the bookmark for @uri was added into @bookmark. 1015 * 1016 * If no bookmark for @uri is found then it is created. 1017 * 1018 * Params: 1019 * uri = a valid URI 1020 * added = a #GDateTime 1021 * 1022 * Since: 2.66 1023 */ 1024 public void setAddedDateTime(string uri, DateTime added) 1025 { 1026 g_bookmark_file_set_added_date_time(gBookmarkFile, Str.toStringz(uri), (added is null) ? null : added.getDateTimeStruct()); 1027 } 1028 1029 /** 1030 * Sets the meta-data of application @name inside the list of 1031 * applications that have registered a bookmark for @uri inside 1032 * @bookmark. 1033 * 1034 * You should rarely use this function; use g_bookmark_file_add_application() 1035 * and g_bookmark_file_remove_application() instead. 1036 * 1037 * @name can be any UTF-8 encoded string used to identify an 1038 * application. 1039 * @exec can have one of these two modifiers: "\%f", which will 1040 * be expanded as the local file name retrieved from the bookmark's 1041 * URI; "\%u", which will be expanded as the bookmark's URI. 1042 * The expansion is done automatically when retrieving the stored 1043 * command line using the g_bookmark_file_get_application_info() function. 1044 * @count is the number of times the application has registered the 1045 * bookmark; if is < 0, the current registration count will be increased 1046 * by one, if is 0, the application with @name will be removed from 1047 * the list of registered applications. 1048 * @stamp is the Unix time of the last registration; if it is -1, the 1049 * current time will be used. 1050 * 1051 * If you try to remove an application by setting its registration count to 1052 * zero, and no bookmark for @uri is found, %FALSE is returned and 1053 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly, 1054 * in the event that no application @name has registered a bookmark 1055 * for @uri, %FALSE is returned and error is set to 1056 * %G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark 1057 * for @uri is found, one is created. 1058 * 1059 * Deprecated: Use g_bookmark_file_set_application_info() instead, as 1060 * `time_t` is deprecated due to the year 2038 problem. 1061 * 1062 * Params: 1063 * uri = a valid URI 1064 * name = an application's name 1065 * exec = an application's command line 1066 * count = the number of registrations done for this application 1067 * stamp = the time of the last registration for this application 1068 * 1069 * Returns: %TRUE if the application's meta-data was successfully 1070 * changed. 1071 * 1072 * Since: 2.12 1073 * 1074 * Throws: GException on failure. 1075 */ 1076 public bool setAppInfo(string uri, string name, string exec, int count, uint stamp) 1077 { 1078 GError* err = null; 1079 1080 auto __p = g_bookmark_file_set_app_info(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), Str.toStringz(exec), count, stamp, &err) != 0; 1081 1082 if (err !is null) 1083 { 1084 throw new GException( new ErrorG(err) ); 1085 } 1086 1087 return __p; 1088 } 1089 1090 /** 1091 * Sets the meta-data of application @name inside the list of 1092 * applications that have registered a bookmark for @uri inside 1093 * @bookmark. 1094 * 1095 * You should rarely use this function; use g_bookmark_file_add_application() 1096 * and g_bookmark_file_remove_application() instead. 1097 * 1098 * @name can be any UTF-8 encoded string used to identify an 1099 * application. 1100 * @exec can have one of these two modifiers: "\%f", which will 1101 * be expanded as the local file name retrieved from the bookmark's 1102 * URI; "\%u", which will be expanded as the bookmark's URI. 1103 * The expansion is done automatically when retrieving the stored 1104 * command line using the g_bookmark_file_get_application_info() function. 1105 * @count is the number of times the application has registered the 1106 * bookmark; if is < 0, the current registration count will be increased 1107 * by one, if is 0, the application with @name will be removed from 1108 * the list of registered applications. 1109 * @stamp is the Unix time of the last registration. 1110 * 1111 * If you try to remove an application by setting its registration count to 1112 * zero, and no bookmark for @uri is found, %FALSE is returned and 1113 * @error is set to %G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly, 1114 * in the event that no application @name has registered a bookmark 1115 * for @uri, %FALSE is returned and error is set to 1116 * %G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark 1117 * for @uri is found, one is created. 1118 * 1119 * Params: 1120 * uri = a valid URI 1121 * name = an application's name 1122 * exec = an application's command line 1123 * count = the number of registrations done for this application 1124 * stamp = the time of the last registration for this application, 1125 * which may be %NULL if @count is 0 1126 * 1127 * Returns: %TRUE if the application's meta-data was successfully 1128 * changed. 1129 * 1130 * Since: 2.66 1131 * 1132 * Throws: GException on failure. 1133 */ 1134 public bool setApplicationInfo(string uri, string name, string exec, int count, DateTime stamp) 1135 { 1136 GError* err = null; 1137 1138 auto __p = g_bookmark_file_set_application_info(gBookmarkFile, Str.toStringz(uri), Str.toStringz(name), Str.toStringz(exec), count, (stamp is null) ? null : stamp.getDateTimeStruct(), &err) != 0; 1139 1140 if (err !is null) 1141 { 1142 throw new GException( new ErrorG(err) ); 1143 } 1144 1145 return __p; 1146 } 1147 1148 /** 1149 * Sets @description as the description of the bookmark for @uri. 1150 * 1151 * If @uri is %NULL, the description of @bookmark is set. 1152 * 1153 * If a bookmark for @uri cannot be found then it is created. 1154 * 1155 * Params: 1156 * uri = a valid URI or %NULL 1157 * description = a string 1158 * 1159 * Since: 2.12 1160 */ 1161 public void setDescription(string uri, string description) 1162 { 1163 g_bookmark_file_set_description(gBookmarkFile, Str.toStringz(uri), Str.toStringz(description)); 1164 } 1165 1166 /** 1167 * Sets a list of group names for the item with URI @uri. Each previously 1168 * set group name list is removed. 1169 * 1170 * If @uri cannot be found then an item for it is created. 1171 * 1172 * Params: 1173 * uri = an item's URI 1174 * groups = an array of 1175 * group names, or %NULL to remove all groups 1176 * 1177 * Since: 2.12 1178 */ 1179 public void setGroups(string uri, string[] groups) 1180 { 1181 g_bookmark_file_set_groups(gBookmarkFile, Str.toStringz(uri), Str.toStringzArray(groups), cast(size_t)groups.length); 1182 } 1183 1184 /** 1185 * Sets the icon for the bookmark for @uri. If @href is %NULL, unsets 1186 * the currently set icon. @href can either be a full URL for the icon 1187 * file or the icon name following the Icon Naming specification. 1188 * 1189 * If no bookmark for @uri is found one is created. 1190 * 1191 * Params: 1192 * uri = a valid URI 1193 * href = the URI of the icon for the bookmark, or %NULL 1194 * mimeType = the MIME type of the icon for the bookmark 1195 * 1196 * Since: 2.12 1197 */ 1198 public void setIcon(string uri, string href, string mimeType) 1199 { 1200 g_bookmark_file_set_icon(gBookmarkFile, Str.toStringz(uri), Str.toStringz(href), Str.toStringz(mimeType)); 1201 } 1202 1203 /** 1204 * Sets the private flag of the bookmark for @uri. 1205 * 1206 * If a bookmark for @uri cannot be found then it is created. 1207 * 1208 * Params: 1209 * uri = a valid URI 1210 * isPrivate = %TRUE if the bookmark should be marked as private 1211 * 1212 * Since: 2.12 1213 */ 1214 public void setIsPrivate(string uri, bool isPrivate) 1215 { 1216 g_bookmark_file_set_is_private(gBookmarkFile, Str.toStringz(uri), isPrivate); 1217 } 1218 1219 /** 1220 * Sets @mime_type as the MIME type of the bookmark for @uri. 1221 * 1222 * If a bookmark for @uri cannot be found then it is created. 1223 * 1224 * Params: 1225 * uri = a valid URI 1226 * mimeType = a MIME type 1227 * 1228 * Since: 2.12 1229 */ 1230 public void setMimeType(string uri, string mimeType) 1231 { 1232 g_bookmark_file_set_mime_type(gBookmarkFile, Str.toStringz(uri), Str.toStringz(mimeType)); 1233 } 1234 1235 /** 1236 * Sets the last time the bookmark for @uri was last modified. 1237 * 1238 * If no bookmark for @uri is found then it is created. 1239 * 1240 * The "modified" time should only be set when the bookmark's meta-data 1241 * was actually changed. Every function of #GBookmarkFile that 1242 * modifies a bookmark also changes the modification time, except for 1243 * g_bookmark_file_set_visited_date_time(). 1244 * 1245 * Deprecated: Use g_bookmark_file_set_modified_date_time() instead, as 1246 * `time_t` is deprecated due to the year 2038 problem. 1247 * 1248 * Params: 1249 * uri = a valid URI 1250 * modified = a timestamp or -1 to use the current time 1251 * 1252 * Since: 2.12 1253 */ 1254 public void setModified(string uri, uint modified) 1255 { 1256 g_bookmark_file_set_modified(gBookmarkFile, Str.toStringz(uri), modified); 1257 } 1258 1259 /** 1260 * Sets the last time the bookmark for @uri was last modified. 1261 * 1262 * If no bookmark for @uri is found then it is created. 1263 * 1264 * The "modified" time should only be set when the bookmark's meta-data 1265 * was actually changed. Every function of #GBookmarkFile that 1266 * modifies a bookmark also changes the modification time, except for 1267 * g_bookmark_file_set_visited_date_time(). 1268 * 1269 * Params: 1270 * uri = a valid URI 1271 * modified = a #GDateTime 1272 * 1273 * Since: 2.66 1274 */ 1275 public void setModifiedDateTime(string uri, DateTime modified) 1276 { 1277 g_bookmark_file_set_modified_date_time(gBookmarkFile, Str.toStringz(uri), (modified is null) ? null : modified.getDateTimeStruct()); 1278 } 1279 1280 /** 1281 * Sets @title as the title of the bookmark for @uri inside the 1282 * bookmark file @bookmark. 1283 * 1284 * If @uri is %NULL, the title of @bookmark is set. 1285 * 1286 * If a bookmark for @uri cannot be found then it is created. 1287 * 1288 * Params: 1289 * uri = a valid URI or %NULL 1290 * title = a UTF-8 encoded string 1291 * 1292 * Since: 2.12 1293 */ 1294 public void setTitle(string uri, string title) 1295 { 1296 g_bookmark_file_set_title(gBookmarkFile, Str.toStringz(uri), Str.toStringz(title)); 1297 } 1298 1299 /** 1300 * Sets the time the bookmark for @uri was last visited. 1301 * 1302 * If no bookmark for @uri is found then it is created. 1303 * 1304 * The "visited" time should only be set if the bookmark was launched, 1305 * either using the command line retrieved by g_bookmark_file_get_application_info() 1306 * or by the default application for the bookmark's MIME type, retrieved 1307 * using g_bookmark_file_get_mime_type(). Changing the "visited" time 1308 * does not affect the "modified" time. 1309 * 1310 * Deprecated: Use g_bookmark_file_set_visited_date_time() instead, as 1311 * `time_t` is deprecated due to the year 2038 problem. 1312 * 1313 * Params: 1314 * uri = a valid URI 1315 * visited = a timestamp or -1 to use the current time 1316 * 1317 * Since: 2.12 1318 */ 1319 public void setVisited(string uri, uint visited) 1320 { 1321 g_bookmark_file_set_visited(gBookmarkFile, Str.toStringz(uri), visited); 1322 } 1323 1324 /** 1325 * Sets the time the bookmark for @uri was last visited. 1326 * 1327 * If no bookmark for @uri is found then it is created. 1328 * 1329 * The "visited" time should only be set if the bookmark was launched, 1330 * either using the command line retrieved by g_bookmark_file_get_application_info() 1331 * or by the default application for the bookmark's MIME type, retrieved 1332 * using g_bookmark_file_get_mime_type(). Changing the "visited" time 1333 * does not affect the "modified" time. 1334 * 1335 * Params: 1336 * uri = a valid URI 1337 * visited = a #GDateTime 1338 * 1339 * Since: 2.66 1340 */ 1341 public void setVisitedDateTime(string uri, DateTime visited) 1342 { 1343 g_bookmark_file_set_visited_date_time(gBookmarkFile, Str.toStringz(uri), (visited is null) ? null : visited.getDateTimeStruct()); 1344 } 1345 1346 /** 1347 * This function outputs @bookmark as a string. 1348 * 1349 * Returns: a newly allocated string holding the contents of the #GBookmarkFile 1350 * 1351 * Since: 2.12 1352 * 1353 * Throws: GException on failure. 1354 */ 1355 public string toData() 1356 { 1357 size_t length; 1358 GError* err = null; 1359 1360 auto retStr = g_bookmark_file_to_data(gBookmarkFile, &length, &err); 1361 1362 if (err !is null) 1363 { 1364 throw new GException( new ErrorG(err) ); 1365 } 1366 1367 scope(exit) Str.freeString(retStr); 1368 return Str.toString(retStr, length); 1369 } 1370 1371 /** 1372 * This function outputs @bookmark into a file. The write process is 1373 * guaranteed to be atomic by using g_file_set_contents() internally. 1374 * 1375 * Params: 1376 * filename = path of the output file 1377 * 1378 * Returns: %TRUE if the file was successfully written. 1379 * 1380 * Since: 2.12 1381 * 1382 * Throws: GException on failure. 1383 */ 1384 public bool toFile(string filename) 1385 { 1386 GError* err = null; 1387 1388 auto __p = g_bookmark_file_to_file(gBookmarkFile, Str.toStringz(filename), &err) != 0; 1389 1390 if (err !is null) 1391 { 1392 throw new GException( new ErrorG(err) ); 1393 } 1394 1395 return __p; 1396 } 1397 1398 /** */ 1399 public static GQuark errorQuark() 1400 { 1401 return g_bookmark_file_error_quark(); 1402 } 1403 1404 /** 1405 * Creates a new empty #GBookmarkFile object. 1406 * 1407 * Use g_bookmark_file_load_from_file(), g_bookmark_file_load_from_data() 1408 * or g_bookmark_file_load_from_data_dirs() to read an existing bookmark 1409 * file. 1410 * 1411 * Returns: an empty #GBookmarkFile 1412 * 1413 * Since: 2.12 1414 * 1415 * Throws: ConstructionException GTK+ fails to create the object. 1416 */ 1417 public this() 1418 { 1419 auto __p = g_bookmark_file_new(); 1420 1421 if(__p is null) 1422 { 1423 throw new ConstructionException("null returned by new"); 1424 } 1425 1426 this(cast(GBookmarkFile*) __p); 1427 } 1428 }